package presenters.component

class RssLayoutComponent {

    def namespace = "rssLayout"

    def build = { posts, blogConfig, callback ->
        builder.rss(version: "2.0") {
            channel {
                title(blogConfig.title)
                link("${startUrl()}/post/list")
                description(blogConfig.description)
                language("en-us")
                posts.each {post ->
                    callback(post)
                }
            }
        }
    }

    def startUrl() {
        return "http://${request.serverName}:${request.serverPort}${request.contextPath}"
    }
}